
#region using
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.Adapters;
#endregion

public class ImageControlAdapter : WebControlAdapter
{
	protected override void Render(HtmlTextWriter writer)
	{
		Image  oImage  = Control as Image;
		string strPath = Page.MapPath(oImage.ImageUrl);

		if (!strPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase) && // If not a PNG extension...
			oImage.Attributes["PNG"] != "true") // And not specifically told this is a PNG...
		{
			base.Render(writer); // Have control render itself
			return;
		}

		string strImageUrl = oImage.ImageUrl;

		writer.Write("<![if !lt IE 7]>");
		base.Render(writer); // Used by non-IE & IE7
		writer.Write("<![endif]>");

		oImage.Style.Add(HtmlTextWriterStyle.Filter, "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + Page.ResolveClientUrl(strImageUrl) + "',sizingMethod='image')");
        //oImage.ImageUrl = Page.ResolveClientUrl("~/spacer.gif");
        oImage.ImageUrl = "~/App_Themes/" + Page.StyleSheetTheme + "/images/spacer.gif"; 

		writer.Write("<!--[if lt IE 7]>");
		base.Render(writer); // Used by IE < 7
		writer.Write("<![endif]-->");
	}
}
